package com.aididi.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: zx.xu
 * @Description:
 */
@Repository
public class RedisDao {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //设置key
    public void setKey(String key,String value){
        ValueOperations<String,String> operations = stringRedisTemplate.opsForValue();
        operations.set(key,value,1000, TimeUnit.SECONDS);
    }

    //获取value
    public String getValue(String key){
        ValueOperations<String,String> operations  = stringRedisTemplate.opsForValue();
        return operations.get(key);
    }


}
